package Practice18;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;

public class ComparatorTest {
    public static void main(String[] args) {
        Person[] array = {
                new Person("古力娜扎", 12),
                new Person("迪丽热巴", 34),
                new Person("玛尔扎哈", 23)
        };
        Comparator<Person> comp = new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getAge() - o2.getAge();
            }
        };
        Arrays.sort(array, comp);
        for (Person person : array) {
            System.out.println(person + ":person");
        }
    }
}
